﻿using System;
using System.Collections;
using ASPNETVN.PORTAL.Components.Configuration.Settings;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Components.UI.DataTypes;

namespace ASPNETVN.PORTAL.Modules.ACTP.MENU
{
    public partial class Main : PortalModuleControl
    {
        public Main()
        {
            ModuleSettingItem itemSetting = new ModuleSettingItem(new StringDataType());
            itemSetting.Value = Guid.Empty.ToString();
            itemSetting.Name = "ModuleID of Module CRM";
            itemSetting.SortOrder = 1;
            this.BaseSettings.Add("ACTP.ModuleID", itemSetting);
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                Hashtable settings = this.Settings;
                odsTeamItems.SelectParameters["ModuleID"].DefaultValue = settings["ACTP.ModuleID"].ToString();
                odsProjectItems.SelectParameters["ModuleID"].DefaultValue = settings["ACTP.ModuleID"].ToString();
                //odsTaskItems.SelectParameters["ModuleID"].DefaultValue = settings["ACTP.ModuleID"].ToString();
                odsEmployeeItems.SelectParameters["ModuleID"].DefaultValue = settings["ACTP.ModuleID"].ToString();
                odsCertificationItems.SelectParameters["ModuleID"].DefaultValue = settings["ACTP.ModuleID"].ToString();

                string url = Request.RawUrl;
                if (url.IndexOf("TeamList") >= 0 || url.IndexOf("TeamSearch") > 0)
                {
                    accordion.SelectedIndex = 1;
                }
                else if (url.IndexOf("ProjectList") >= 0 || url.IndexOf("ProjectSearch") > 0)
                {
                    accordion.SelectedIndex = 0;
                }
                else if (url.IndexOf("EmployeeList") >= 0 || url.IndexOf("EmployeeSearch") > 0)
                {
                    accordion.SelectedIndex = 1;
                }
                else if (url.IndexOf("CertificationList") >= 0 || url.IndexOf("CertificationSearch") > 0)
                {
                    accordion.SelectedIndex = 2;
                }
            }
        }
    }
}